<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new MovealbumsCtl();
	$ctl->checkAdmin();
	$ctl->checkNotReadonly();
	$ctl->proceed();
	
	$header = new Header();
	$header->render('Move Albums Between Users');
	
	// getting the form and proceed
	$form = $ctl->getMovealbumsForm();
	
	$albums = $form->getAlbums();
	$users = $form->getUsers();
	$selected = $form->getSelected();
	
	$searchUserId = $form->getSearchUserId();
	$moveUserId = $form->getMoveUserId();

	// get the ids and the lists and proceed with it
	$searchUsers = HtmlUtil::getComboBox('searchUserId', $users, 'getId', 'getName', $searchUserId);
	$moveUsers = HtmlUtil::getComboBox('moveUserId', $users, 'getId', 'getName', $moveUserId);
?>
<form method="post">
<input type="hidden" name="pagename" value="movealbums" id="pgid">
<input type="hidden" name="metname" value="" id="metid">

<h2>Move Albums Between Users</h2>
<h3>Please select the albums to move, select <br>
the destination album and then proceed</h3>
<table cellpadding="4" cellspacing="0" class="list" width="350px">
	<tr>
		<td colspan="2">User: <?php echo $searchUsers; ?> <input type="button" value="Update" onclick="triggerform('update');"></td>
	</tr>
	<tr>
		<td>Select</td>
		<td width="100%">Album</td>
	</tr>
	<?php
	foreach($albums as $current) { 
		$id = $current->getId();
		$name = htmlspecialchars($current->getName());
		$sel = array_key_exists($id, $selected);
		
		$checkbox = HtmlUtil::getCheckbox('selected[]', $id, $sel, array());
	?>
	<tr>
		<td><div align="center"><?php echo $checkbox; ?></div></td>
		<td nowrap><?php echo $name; ?></td>
	</tr>
	<?php 
	}
	?>
	<tr>
		<td colspan="2">Destination: <?php echo $moveUsers; ?><input type="button" value="Move" onclick="triggerform('move');"></td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
